
<@ms.html5>
    <@ms.nav title="保险公司管理"></@ms.nav>
    <@ms.searchForm name="searchForm" isvalidation=true>
            <@ms.searchFormButton>
                 <@ms.queryButton onclick="search()"/> 
            </@ms.searchFormButton>            
    </@ms.searchForm>
    <@ms.panel>
        <div id="toolbar">
            <@ms.panelNav>
                <@ms.buttonGroup>
                    <@ms.addButton id="addPorpertyBtn"/> 
                    <@ms.delButton id="delPropertyBtn"/> 
                </@ms.buttonGroup>
            </@ms.panelNav>
        </div>
        <table id="companyList" 
            data-show-refresh="true"
            data-show-columns="true"
            data-show-export="true"
            data-method="post" 
            data-pagination="true"
            data-page-size="10"
            data-side-pagination="server">
        </table>
    </@ms.panel>

    <@ms.modal  modalName="delArticle" title="保险公司删除" >
        <@ms.modalBody>删除此授权
            <@ms.modalButton>
                <!--模态框按钮组-->
                <@ms.button  value="确认删除？"  id="deleteArticleBtn"  />
            </@ms.modalButton>
        </@ms.modalBody>
    </@ms.modal>
</@ms.html5>

<script>
    $(function(){
        $("#companyList").bootstrapTable({
            url:"${managerPath}/goods/company/list.do",
            contentType : "application/x-www-form-urlencoded",
            queryParamsType : "undefined",
            toolbar: "#toolbar",
            columns: [{ checkbox: true},
                        {
                            field: 'companyId',
                            title: '属性ID',
                            width:'10',
                            align: 'center',
                            formatter:function(value,row,index) {
                                var url = "${managerPath}/goods/company/form.do?companyId="+row.companyId;
                                return "<a href=" +url+ " target='_self'>" + value + "</a>";
                            }
                        },{
                            field: 'companyName',
                            title: '保险公司名称',
                            width:'65',
                            formatter:function(value,row,index) {
                                var url = "${managerPath}/goods/company/form.do?companyId="+row.companyId;
                                return "<a href=" +url+ " target='_self'>" + value + "</a>";
                            }

                      
                        },{
                            field: 'linkman',
                            title: '联系人',
                            width:'65'
                        },{
                            field: 'mobile',
                            title: '电话',
                            width:'65'
                       },{
                            field: 'companySort',
                            title: '排序',
                            width:'65'
                        },{
                            field: 'createDate',
                            title: '创建时间',
                            width:'65'
                        }]
        })
    })
    //增加按钮
    $("#addPorpertyBtn").click(function(){
        location.href ="${managerPath}/goods/company/form.do"; 
    })
    //删除按钮
    $("#delPropertyBtn").click(function(){
        //获取checkbox选中的数据
        var rows = $("#companyList").bootstrapTable("getSelections");
        //没有选中checkbox
        if(rows.length <= 0){
            <@ms.notify msg="请选择需要删除的记录" type="warning"/>
        }else{
            $(".delArticle").modal();
        }
    })

    $("#deleteArticleBtn").click(function(){
        var rows = $("#companyList").bootstrapTable("getSelections");
        $(this).text("正在删除...");
        $(this).attr("disabled","true");
        $.ajax({
            type: "post",
            url: "${managerPath}/goods/company/delete.do",
            data: JSON.stringify(rows),
            dataType: "json",
            contentType: "application/json",
            success:function(msg) {
                if(msg.result == true) {
                    <@ms.notify msg= "删除成功" type= "success" />
                }else {
                    <@ms.notify msg= "删除失败" type= "fail" />
                }
                location.reload();
            }
        })
    });
    //查询功能
    function search(){
        var search = $("form[name='searchForm']").serializeJSON();
        var params = $('#companyList').bootstrapTable('getOptions');
        params.queryParams = function(params) {  
            $.extend(params,search);
            return params;  
           }  
            $("#companyList").bootstrapTable('refresh', {query:$("form[name='searchForm']").serializeJSON()});
    }
</script>